package com.lft.doublelinkedlist;

public class DoubleLinkedListDemo {
	public static void main(String[] args) {
		
		HeroNode head = new HeroNode(0, "", "");
		
		// 链表一所需的三个节点。
		HeroNode hero11 = new HeroNode(1, "宋江", "及时雨");
		HeroNode hero12 = new HeroNode(2, "卢俊义", "玉麒麟");
		HeroNode hero13 = new HeroNode(3, "吴用", "智多星");
		
		// 链表二所需的三个节点。
		HeroNode hero21 = new HeroNode(4, "林冲", "豹子头");
		HeroNode hero22 = new HeroNode(5, "鲁智深", "花和尚");
		HeroNode hero23 = new HeroNode(6, "武松", "行者");
		
		// 用于修改的一个节点。
		HeroNode hero37 = new HeroNode(3, "时迁", "鼓上蚤");
		
		// 用于删除的一个节点
		HeroNode hero38 = new HeroNode(4, "武大娘", "顾大嫂");
		
		head = DoubleLinkedListUtil.addByOrder(head, hero13);
		head = DoubleLinkedListUtil.addByOrder(head, hero38);
		head = DoubleLinkedListUtil.addByOrder(head, hero12);
		head = DoubleLinkedListUtil.addByOrder(head, hero11);
		
		System.out.println("添加节点后——遍历");
		DoubleLinkedListUtil.list(head.next);
		
		System.out.println();
		head = DoubleLinkedListUtil.update(head, hero37);
		System.out.println("修改节点后——遍历");
		DoubleLinkedListUtil.list(head.next);
		
		System.out.println();
		head = DoubleLinkedListUtil.delete(head, 4);
		System.out.println("删除节点后——遍历");
		DoubleLinkedListUtil.list(head.next);
		
	}
}
